package com.ophiux.cs.application.user.remote;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.cs.application.consultBase.dto.GetCSDoctorInfoByIDRequest;
import com.ophiux.cs.application.consultBase.dto.GetCSDoctorInfoByIDResponse;
import com.ophiux.cs.application.consultBase.service.IGetCSDoctorsAppService;
import com.ophiux.cs.application.core.Result;
import com.ophiux.cs.domain.user.model.valueobj.User_DoctorApi;
import com.ophiux.cs.domain.user.remote.IUser_DoctorRemoteService;
import com.ophiux.utils.exception.OphiuxRemoteException;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class User_DoctorRemoteService implements IUser_DoctorRemoteService{
	@Autowired
	IGetCSDoctorsAppService getCSDoctorsAppService;

	@Override
	public User_DoctorApi getDoctorInfoByDoctorId(String doctorId) throws OphiuxRemoteException {
		
		try {
			GetCSDoctorInfoByIDRequest req = new GetCSDoctorInfoByIDRequest();
			req.setDOCTOR_ID(doctorId);
			
			Result<GetCSDoctorInfoByIDResponse> result = getCSDoctorsAppService.GetCSDoctorInfoByID(req);
			User_DoctorApi resp = null;
			if(result.isSuccess()) {
				log.info("User_DoctorRemoteService=>getDoctorInfoByDoctorId()远程API调用成功");
				resp = new User_DoctorApi();
				resp.setCERTIFICATE_NO(result.getRESPONSE().getZY_CERTIFICATE_NO());
				resp.setHOSPITAL_NAME(result.getRESPONSE().getHOSPITAL_NAME());
				resp.setDEPT_NAME(result.getRESPONSE().getDEPT_NAME());
				resp.setTECHNICAL_TITLE(result.getRESPONSE().getTECHNICAL_TITLE());
				
			}else {
				log.info("User_DoctorRemoteService=>getDoctorInfoByDoctorId()远程API调用失败");
			}
			
			return resp;
		} catch (Exception e) {
			e.printStackTrace();
			log.info("调用远程API,getConsultOrderIsExist异常",e);
			throw new OphiuxRemoteException(e);
		}
	}

	
	
}
